// 中间代理
class EventEmitter {
    public subs: any
    constructor() {
        this.subs = {}
    }
    public on = (eventType: string, handler: any) => {
        this.subs[eventType] = this.subs[eventType] || [];
        this.subs[eventType].push(handler)
    }
    public emit = (eventType: string, ...rest: any) => {
        if (this.subs[eventType]) {
            this.subs[eventType].forEach((handler: any) => {
                handler.call(this, ...rest)
            })
        }
    }
    public getUserBtn(title:string) {
        return this.subs[title] && this.subs.getUserBtn
    }
    public getMenuList(title:string) {
        return this.subs[title] && this.subs.getMenuList
    }
    public register(title:string,data:any[]) {
        this.subs[title] = data
    }
}

export const mediator = new EventEmitter();